﻿using System.Text;
using CompactMapper.Orm.Extensions;
using CompactMapper.Orm.UnitOfWork.Mappings;

namespace CompactMapper.Orm.UnitOfWork.Commands.Criteria
{
    internal sealed class StringEqualsCriterion<T> : Criterion<T>
    {
        private const string Equal = " = ";

        public StringEqualsCriterion(Queries.Criterion<T> criterion, TablesTree tablesTree)
            : base(criterion, tablesTree)
        {
        }

        protected override string ToSql()
        {
            var sql = new StringBuilder()
                .Append(PropertyName.ToSqlColumn())
                .Append(Equal)
                .Append("'")
                .Append(TargetValue)
                .Append("'")
                .ToString();
            return sql;
        }
    }
}